<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page import="java.sql.Connection" %>
<%@ page import="java.sql.Statement" %>
<%@ page import="java.sql.ResultSet" %>
<%@ page import="java.sql.DriverManager" %>
<!doctype html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>萌推电商</title>
    <link rel="stylesheet" type="text/css" href="../css/common.css"/>
    <link rel="stylesheet" type="text/css" href="../css/main.css"/>
    <script src="http://libs.baidu.com/jquery/2.1.4/jquery.min.js"></script><!--需要引入-->
</head>
<body>
<script type="text/javascript">
    $(window).load(function() {
        var str="<%=request.getParameter("str")%>";
        if (str=="flag") {alert("产品数量不足");}
    });
</script>
<div class="topbar-wrap white">
    <div class="topbar-inner clearfix">
        <div class="topbar-logo-wrap clearfix">
            <h1 class="topbar-logo none"><a href="../index.jsp" class="navbar-brand">萌推电商</a></h1>
            <ul class="navbar-list clearfix">
                <li><a class="on" href="#">首页</a></li>
                <li><a href="#" target="#">网站首页</a></li>
            </ul>
        </div>
        <div class="top-info-wrap">
            <ul class="top-info-list clearfix">
                <li><a href="#">管理员</a></li>
                <li><a href="#">修改密码</a></li>
                <li><a href="#">退出</a></li>
            </ul>
        </div>
    </div>
</div>
<div class="container clearfix">
    <div class="sidebar-wrap">
        <div class="sidebar-title">
            <h1>菜单</h1>
        </div>
        <div class="sidebar-content">
            <ul class="sidebar-list">
                <li>
                    <a href="#"><i class="icon-font">&#xe003;</i>人事管理</a>
                    <ul class="sub-menu">
                        <li><a href="design.html"><i class="icon-font">&#xe008;</i>部门管理</a></li>
                        <li><a href="design.html"><i class="icon-font">&#xe005;</i>员工管理</a></li>
                    </ul>
                </li>
                <li>
                    <a href="#"><i class="icon-font">&#xe018;</i>业务管理</a>
                    <ul class="sub-menu">
                        <li><a href="../UserManager/user.jsp"><i class="icon-font">&#xe046;</i>用户管理</a></li>
                        <li><a href="../ShopManager/shop.jsp"><i class="icon-font">&#xe033;</i>店铺管理</a></li>
                        <li><a href="../ProductManager/product.jsp"><i class="icon-font">&#xe006;</i>商品管理</a></li>
                        <li><a href="order.jsp"><i class="icon-font">&#xe006;</i>订单管理</a></li>
                    </ul>
                </li>
            </ul>
        </div>
    </div>
    <!--/sidebar-->
    <div class="main-wrap">
        <div class="crumb-wrap">
            <div class="crumb-list"><i class="icon-font">&#xe06b;</i><span>订单不可修改，谨慎填写</span></div>
        </div>
        <div class="crumb-wrap">
            <div class="crumb-list"><i class="icon-font"></i><a href="#">首页</a><span class="crumb-step">&gt;</span><a class="crumb-name" href="order.jsp">订单管理</a><span class="crumb-step">&gt;</span><span>新增订单</span></div>
        </div>
        <div class="result-wrap">
            <div class="result-content">
                <form action="/final/Addorder" method="post" id="myform" name="myform" enctype="application/x-www-form-urlencoded">
                    <table class="insert-tab" width="100%">
                        <tbody>
                        <tr>
                            <th width="120">用户id：</th>
                            <td>
                                <select name="us_id" id="#" class="required">
                                    <%
                                        int uss_id=0;
                                        try {
                                            Connection con = null;
                                            Statement stmt = null;
                                            ResultSet rs = null;
                                            Class.forName("org.h2.Driver");
                                            /*url后面加的?useUnicode=true&characterEncoding=gbk，是为了处理向数据库中添加数据时出现乱码的问题。*/
                                            String url = "jdbc:h2:~/test5";
                                            con = DriverManager.getConnection(url, "sa", "sa");
                                            stmt = con.createStatement();
                                            String sql =  "select us_id from user ";
                                            rs = stmt.executeQuery(sql);
                                            while (rs.next()) {
                                                uss_id=rs.getInt("us_id");%>
                                    <option value="<%=uss_id%>"><%=uss_id%></option><%
                                        }
                                        rs.close();
                                        stmt.close();
                                        con.close();
                                    }catch (Exception e){e.getMessage();}
                                %>
                                </select>
                            </td>
                        </tr>
                        <tr>
                            <th width="120">商品id：</th>
                            <td>
                                <select name="pr_id" id="" class="required">
                                    <%
                                        int prs_id=0;
                                        try {
                                            Connection con = null;
                                            Statement stmt = null;
                                            ResultSet rs = null;
                                            Class.forName("org.h2.Driver");
                                            /*url后面加的?useUnicode=true&characterEncoding=gbk，是为了处理向数据库中添加数据时出现乱码的问题。*/
                                            String url = "jdbc:h2:~/test5";
                                            con = DriverManager.getConnection(url, "sa", "sa");
                                            stmt = con.createStatement();
                                            String sql =  "select pr_id from product ";
                                            rs = stmt.executeQuery(sql);
                                            while (rs.next()) {
                                                prs_id=rs.getInt("pr_id");%>
                                    <option value="<%=prs_id%>"><%=prs_id%></option><%
                                        }
                                        rs.close();
                                        stmt.close();
                                        con.close();
                                    }catch (Exception e){e.getMessage();}
                                %>
                                </select>
                            </td>
                        </tr>
                        <tr>
                            <th>数量：</th>
                            <td><input class="common-text" name="number" size="50"  type="number" required="required"></td>
                        </tr>
                        <tr>
                            <th>日期：</th>
                            <td><input class="common-text" name="date" size="50"  type="datetime-local" required="required"></td>
                        </tr>
                        <tr>
                            <th></th>
                            <td>
                                <input class="btn btn-primary btn6 mr10" value="提交" type="submit">
                                <input class="btn btn6" onClick="history.go(-1)" value="返回" type="button">
                            </td>
                        </tr>
                        </tbody></table>
                </form>
            </div>
        </div>

    </div>
    <!--/main-->
</div>
</body>
</html>